function selectType() {

	var iptsP4n = document.getElementsByTagName("select");
	for (i = 0; i < iptsP4n.length; i++)

	{

		var slkt = iptsP4n[i];
		var atts = slkt.attributes;
		for (j = 0; j < atts.length; j++) {
			var at = atts[j];
			// if start with
			try {
				if (at.nodeValue)
					if (at.nodeValue.indexOf("load_category") == 0)

					{
						slkt.options[0].selected = true;
						break;
					}
			} catch (e) {
			}
		}

	}

}	
	
	function tryx(func) {
		try {
			func();
		} catch (e) {

		//	 alert("login.js tryx::" + e.number + ":" + e.message + "  " + e.stack);
		}
	}
	
	
	  function  submitConfirm(){
			// document.getElementsByName("submit").item(0).click();
			
//			var code=document.getElementById('captcha').value;
//		 	if(code.length==4)
//		 	{
//		 		
//		 	}else
//		 			window.setTimeout(submitConfirm,4000);		 			
//			
		  if(confirm("内容已经填写上了，需要提交吗"))
	 			document.getElementsByName("submit").item(0).click();//exit timer
		}	

try {


	//alert("a");
	function jsSelectItemByValue(objSelect_id, objItemText) {

		var objSelect = document.getElementById(objSelect_id);
		for (var i = 0; i < objSelect.options.length; i++) {
			if (objSelect.options[i].value == objItemText) {
				objSelect.options[i].selected = true;
				break;
			}
		}
	}
	function copyImg(controlId) {

		var Url2 = document.getElementById(controlId);
		//	alert(Url2.src);
		controlRange = document.body.createControlRange();
		//	alert("a1");
		controlRange.addElement(Url2);
		//	alert("a2");
		controlRange.execCommand('Copy');
	}

	

	
	function submitConfirm() {
		// document.getElementsByName("submit").item(0).click();

		var code = document.getElementById('captcha').value;
		if (code.length == 4) {
			if (confirm("验证码已经填写上了，需要提交吗"))
				document.getElementsByName("submit").item(0).click();//exit timer
		} else
			window.setTimeout(submitConfirm, 4000);

	}

	function setAns(s) {
		//alert(s);
		try {
			s = s.replace("=?", "");
			var rzt = eval(s);
			document.getElementById('answer').value = rzt;
		} catch (e) {
			//invok java prob lib solu
		}
		//	  document.getElementById('captcha').value="";
		document.getElementById('captcha').focus();

		//	alert(rzt);
		try {
			//for invok raw check for can suto sumbit
			//	  checkanswer(rzt);
		} catch (e) {
			alert(e);
		}

		//end
	}

	//auto setQuestAns 
	function getQuest() {
		//  window.clearInterval(int)
		var s = document.getElementById('questionstr').innerText;

		if (s.length > 0) {
			window.clearInterval(cyc_id);

			setAns(s);

		}

	}
	// captch png 
	function crackCaptch() {
		//  window.clearInterval(int)

		var img = document.getElementById('captchapng');
		if (img.width > 10) {
			window.clearInterval(crackCaptch_handle);

			copyImg("captchapng");
			mycallJava("getCaptch");
		}

	}

	tryx(function() {
		document.getElementsByName("post[typeid]").item(0).value = "0";
	});

//	document.getElementsByName("post[catid]").item(0).value = "1";
//	document.getElementById('title').value = 'title';
//	document.getElementsByName("post[brand]").item(0).value = "我们的品牌";
//	document.getElementsByName("post[content]").item(0).value = "信息说明信息说明信息说明信息说明";
	tryx(function() {
		document.getElementById('business').value = '经营范围@sob经营范围@sob'; //min 10  char
		
		document.getElementById('regyear').value = '2015';
		  jsSelectItemByValue("type","企业单位");	
	});
	
	  
	tryx(function() {
		document.getElementById('daddress').value = '地址地址地址地址地址地址';
		document.getElementById('telephone').value = '020-88888888';
		document.getElementById('introduce').value = '介绍介绍介绍介绍介绍介绍';
	  
		
			window.setTimeout(function() {
				//alert("aa");
				try{
				 selectType();}catch(e){ alert("login.js select type()::" + e.number + ":" + e.message + "  " + e.stack); }
				// alert("bb");
				 addcate(6);
			}, 2000);
		
	//	var optionObj = new Option("公司默认分类", 3, false, true); //默认选中
	//	document.getElementById("cates").options.add(optionObj);
	});
	  

//	reloadquestion();
	//reloadquestion();
	//   showcaptcha();

//	var cyc_id = window.setInterval(getQuest, 2000);
//
//	var crackCaptch_handle = window.setInterval(crackCaptch, 2000);

	// $("#username").value="aaa";
	//	 alert($("#username").value);
	//document.getElementById('password').value='000000';

	// var arrP4a=document.getElementsByName("submit");
	//	 alert("a10:"+arrP4a);
	//	 var a1=arrP4a[0];
	//	 alert("a1:"+a1);
	//	 var a2=arrP4a.item(0);
	//	 alert("a2:"+a2);
	window.setTimeout(function() {
		// document.getElementsByName("submit").item(0).click();

	}, 3000);

	//window.setTimeout(function(){
	//	alert("start to pub");
	//window.location="http://localhost/destoon/member/my.php?mid=5&action=add&aP4=js";
	//},25000);
	
	window.setTimeout(submitConfirm,4000);

} catch (e) {

	alert("finish info js::" + e.number + ":" + e.message + "  " + e.stack);
}